﻿namespace KeyStone.Ioc.Attributes
{
   using System;

   /// <summary>
   /// Class RegisteredDependencyAttribute.
   /// </summary>
   /// <remarks>
   /// Adding this attribute to a class will mark the class as a dependency that should be registered
   /// This should be used in conjunction with RegisterTypesOf&lt;T&gt;()
   /// 
   /// Specifying The RegisteredDependency attribute or another class derived from it will allow
   /// the type to be auto registered. In this instance, the first interface that is encountered 
   /// will be the interface that is mapped to the instance of the concrete type.
   /// </remarks>
   [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
   public class RegisteredDependencyAttribute : Attribute
   {
      /// <summary>
      /// Gets or sets the lifetime.
      /// </summary>
      /// <remarks>
      /// Currently this can be Singleton or Per-Instance</remarks>
      /// <value>The lifetime.</value>
      public Lifetime Lifetime { get; set; }

      /// <summary>
      /// Initializes a new instance of the <see cref="RegisteredDependencyAttribute"/> class.
      /// </summary>
      /// <param name="lifeTime">The life time.</param>
      public RegisteredDependencyAttribute(Lifetime lifeTime)
      {
         Lifetime = lifeTime;
      }

      /// <summary>
      /// Initializes a new instance of the <see cref="RegisteredDependencyAttribute"/> class.
      /// </summary>
      public RegisteredDependencyAttribute()
      {
         Lifetime = Lifetime.PerInstance;
      }
   }
}
